package j05zuoye;

class Point{
    int x;
    int y;

    public Point() {
    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    //普通方法
    public double distanceTo(Point p){
        int disX = p.x - x;
        int disY = p.y - y;


        return Math.sqrt(disX*disX + disY*disY);
    }

    public void printPointInfo() {
        System.out.println( "Point{" +
                "x=" + x +
                ", y=" + y +
                '}'
        );
    }
}
public class J5point {
    public static void main(String[] args) {
        //开方
//        System.out.println(Math.sqrt(4));//2
//        System.out.println(Math.sqrt(16));//4


        Point p1 = new Point(0,0);
        p1.printPointInfo();

        Point p2 = new Point(3,4);

        double distance = p1.distanceTo(p2);
        System.out.println("distance = " + distance);
    }
}
